<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .canvas{
            border: 1px solid red;
        }
    </style>
</head>
<body>
<canvas class="canvas" width="600px" height="400px">
    您的浏览器不支持
</canvas>

<script>
    var canvas = document.getElementsByClassName('canvas')[0]
    var ctx = canvas.getContext('2d')
    //阴影的X偏移
    ctx.shadowOffsetX = 20
    //阴影的Y偏移
    ctx.shadowOffsetY = 20
    //阴影的颜色
    ctx.shadowColor = 'rgba(0,0,0,0.5)'
    //阴影的模糊程度
    ctx.shadowBlur = 10
    ctx.fillStyle = 'rgba(255,0,0,0.5)'
    ctx.fillRect(100,100,100,100)




</script>
</body>
</html>
